#include <iostream>
#include <vector>
using namespace std;

class Solution {
private:
    int getLeft(vector<int>& nums, int target){
        int left = 0;
        int right = nums.size() - 1;
        while(left < right){
            int mid = (left + right) / 2;
            if(nums[mid] >= target) right = mid;
            else left = mid + 1;
        }
        if(nums[left] == target) return left;
        return -1;
    }
    int getRight(vector<int>& nums, int target){
        int left = 0;
        int right = nums.size() - 1;
        while(left < right){
            int mid = (left + right + 1) / 2;
            if(nums[mid] <= target) left = mid;
            else right = mid - 1;
        }
        if(nums[left] == target) return left;
        return -1;
    }
public:
    vector<int> searchRange(vector<int>& nums, int target) {
        vector<int> res = {-1,-1};
        if(nums.size() == 0) return res;

        res[0] = getLeft(nums,target);
        res[1] = getRight(nums,target);
        return res;
    }
};

int main()
{
    vector<int> nums = {5,7,7,8,8,10};
    Solution sol;
    vector<int> res = sol.searchRange(nums,8);
    cout << "{" << res[0] << "," << res[1] << "}" << endl;
    return 0;
}